Particle Cloud

Using the same setup as detailed_look.jl or example2(), here we simulate a point cloud getting advected by the flow field. For additional documentation e.g. see : 1, 2, 3, 4

1. Import Software

using IndividualDisplacements, OrdinaryDiffEq, Statistics
p=dirname(pathof(IndividualDisplacements))
include(joinpath(p,"../examples/recipes_plots.jl"))
include(joinpath(p,"../examples/example123.jl"));

2. Setup Problem

๐‘ƒ,ฮ“=example2_setup()

ii1=5:5:40; ii2=5:5:25
x=vec([x-0.5 for x in ii1, y in ii2])
y=vec([y-0.5 for x in ii1, y in ii2])
xy = permutedims([[x[i];y[i];1.0] for i in eachindex(x)])

solv(prob) = solve(prob,Tsit5(),reltol=1e-6,abstol=1e-6)
tr = DataFrame(ID=Int[], x=Float64[], y=Float64[], t=Float64[])

#๐ผ = Individuals{Float64,2}(๐Ÿ“Œ=xy[:,:], ๐Ÿ”ด=tr, ๐Ÿ†”=collect(1:size(xy,2)),

0 rows ร— 4 columns

IDxyt
Int64Float64Float64Float64
                    ๐Ÿš„ = dxdt!, โˆซ = solv, ๐Ÿ”ง = postprocess_xy, ๐‘ƒ=๐‘ƒ);
I=(position=xy,record=deepcopy(tr),velocity=dxdt!,
   integration=solv,postprocessing=postprocess_xy,parameters=๐‘ƒ)
๐ผ=Individuals(I)
  ๐Ÿ“Œ details     = (1, 40) Vector{Float64}
  ๐Ÿ”ด details     = (0, 4) ["ID", "x", "y", "t"]
  ๐Ÿ†” range       = (1, 40)
  ๐Ÿš„ function    = dxdt!
  โˆซ  function    = solv
  ๐Ÿ”ง function    = postprocess_xy
  ๐‘ƒ  details     = (:u0, :u1, :v0, :v1, :๐‘‡)

3. Compute Trajectories

๐‘‡ = (0.0,2998*3600.0)
โˆซ!(๐ผ,๐‘‡)
1ร—40 Matrix{Vector{Float64}}:
 [6.2601, -11.4048, 1.0]  [10.9042, 123.049, 1.0]  โ€ฆ  [29.8254, 21.0132, 1.0]

4. Display results

๐ผ.๐Ÿ”ด.lon=5000*๐ผ.๐Ÿ”ด.x
๐ผ.๐Ÿ”ด.lat=5000*๐ผ.๐Ÿ”ด.y
plt=plot_paths(๐ผ.๐Ÿ”ด,size(xy,2),100000.0)

Compare with trajectory output from MITgcm

#IndividualDisplacements.flt_example_download()
#df=read_flt(IndividualDisplacements.flt_example_path,Float32)
#ref=plot_paths(df,size(xy,2),100000.0)

This page was generated using Literate.jl.